﻿@{
    Layout = null;
    var uid = (Session["user"] as WebAppModel.UserScanQRInfoModel).Uid;
    var TId = (Session["user"] as WebAppModel.UserScanQRInfoModel).TId;
}

<!DOCTYPE html>

<html>
<head>
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">

    <title></title>
    <script src="~/Content/Script/jquery.min.js"></script>
    <script src="~/Scripts/base64.js"></script>
    <style>
        * {
            padding: 0;
            margin: 0;
            cursor:pointer;
      
        }
         #LoadingBar {
            position:absolute;
            background-color: rgba(0,0,0,.85);
            width: 100%;
            height: 100%;
            display:flex;
            align-items:center;
            justify-content:center;
            z-index:999;
        }
        ul.my-award {
            width: 100%;
            height: 100%;
            position: absolute;
            color: #FDBE9B;
        }
            ul.my-award a {
                display: flex;
                justify-content: space-between;
                align-items: center;
                border-bottom: 1px solid #FDBE9B;
                padding: 0 15px;
                text-decoration: none;
                height: 55px;
                color:#FDBE9B;
            }
            ul.my-award a > div:nth-child(1) > div:nth-child(2) {
           
                font-size:14px;
            }

        .btn {
            background: #F1F5F6;
            color: gray;
            border: none;
            padding: 4px 12px;
            font-size: 14px;
            line-height: 1.6;
            border-radius: 3px;
            text-align: center;
        }
    </style>
</head>
<body>
    <div id="LoadingBar">
        <img src="~/Content/Images/redpack/loading.gif" />
    </div>
  

</body>
</html>
<script src="~/Content/Script/jquery.min.js"></script>
<script>

    function closePage() {
        WeixinJSBridge.call('closeWindow');
    }
    $.ajax({
        url: "MyPrizeRecordHtml",
        data: { Tid: '@TId' },
        type: "post",
        success: function (res) {

            var html = decode(res);

            $("body").append(html);

            $('title').text($('.pageTitle > span').text());
            $('.pageTitle').remove();
            getInfo();
        }
    });

     
        function DateFormat(val) {
            var date = new Date(parseInt(val.replace("/Date(", "").replace(")/", ""), 10));
            //月份为0-11，所以+1，月份小于10时补个0
            var month = date.getMonth() + 1 < 10 ? "0" + (date.getMonth() + 1) : date.getMonth() + 1;
            var currentDate = date.getDate() < 10 ? "0" + date.getDate() : date.getDate();
            var currentHour = date.getHours();
            var currentMin = date.getMinutes();
            var currentSecond = date.getSeconds();
            var dd = date.getFullYear() + "-" + month + "-" + currentDate;
            return dd;
        }

        //获取我的中奖记录数据
        function getInfo() {
            $.ajax({
                type: "get",
                url: '/app/WebTemplate/GetTheWinningList',
                data: {
                    pageSize: 10,
                    uId: " @uid"
                },
                success: function (data) {
                    $('.my-award').html('');
               
                    if (data.PageData.length<=0) {
                        $('.my-award').append("<div style='text-align:center;width:100%;margin-top:20px; color:#FDBE9B;'>您还没有领奖记录</div>");
                    }
                    $(data.PageData).each(function (i, ele) {
                        var words = '';
                        if (ele.type == 1)//红包
                        {
                            words = '获得' + ele.Denomination.toFixed(2) + '元微信红包';
                        }
                        else if (ele.type == 2)//优惠券
                        {
                            words = '获得' + ele.Denomination.toFixed(2) + '元优惠券';
                        }
                        else if (ele.type == 3) {//流量
                            words = '获得' + ele.Denomination.toFixed(2) + '元流量券';
                        }
                        var e = '<a  href=PrizeDetailsShow?tId=' + ele.Id + '>\n' +
    '            <div>' +
    '                <div>' + words + '</div>' +
    '                <div>' + DateFormat(ele.Time) + '</div>' +
    '            </div>' +
    '            <button class="btn btn-default">已领取</button>' +
    '        </a>';
                        $('.my-award').append(e);
                    })

                    function initPage() {
                        var objLoading = document.getElementById("LoadingBar");
                        if (objLoading != null) {
                            objLoading.style.display = "none";
                        }
                    }
                   initPage();

                },
                error: function (r) {
                    alert(r.status)
                }
            });
        }



</script>